﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Oracle;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;

namespace FA_Server
{
   public class DAC
    {

        #region Fields
        
        private string _boinfo;
        private ConnPositionEnum _connPosition;
        private string _connstring;
        private string _corpCode;
        private string _dataConnString;
        private Database _db;
        private string _dbinfo;
        private string _providerName;
        private string _systemConnString;
        private DataTable dtError;
       // private static Log4net log;
        private bool logFlag;
        #endregion



        #region Methods

        public DbConnection CreateConnection()
        {
            if (this._db == null)
            {
                this._db = new OracleDatabase(Server.GetSystemConnectionString());
            }
            return this._db.CreateConnection();
        }
        public void AddInParameter(DbCommand command, string name, DbType dbType)
        {
            this._db.AddInParameter(command, name, dbType);
        }



        public void AddInParameter(DbCommand command, string name, DbType dbType, object value)
        {
            this._db.AddInParameter(command, name, dbType, value);
        }

        public static void ClearParameterCache()
        {
            Database.ClearParameterCache();
        }

        public DataSet ExecuteDataSet(DbCommand command)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(command);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataSet ExecuteDataSet(string commandText)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(CommandType.Text, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataSet ExecuteDataSet(string[] commandText)
        {
            DataSet set = new DataSet();
            for (int i = 0; i < commandText.Length; i++)
            {
                DataTable table = this.ExecuteDataTable(commandText[i]);
                if (set.Tables.Contains(table.TableName))
                {
                    table.TableName = table.TableName + i.ToString();
                }
                set.Tables.Add(table);
            }
            return set;
        }

        public DataSet ExecuteDataSet(DbCommand command, DbTransaction transaction)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(command, transaction);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataSet ExecuteDataSet(DbTransaction transaction, string commandText)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(transaction, CommandType.Text, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataSet ExecuteDataSet(DbTransaction transaction, string[] commandText)
        {
            DataSet set = new DataSet();
            for (int i = 0; i < commandText.Length; i++)
            {
                set.Tables.Add(this.ExecuteDataTable(commandText[i], transaction));
            }
            return set;
        }

        public DataSet ExecuteDataSet(string commandText, DbTransaction transaction)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(transaction, CommandType.Text, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataSet ExecuteDataSet(string storedProcedureName, params object[] parameterValues)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功（通过存储过程）] ", storedProcedureName, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "（通过存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataSet ExecuteDataSet(DbTransaction transaction, CommandType commandType, string commandText)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(transaction, commandType, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataSet ExecuteDataSet(DbTransaction transaction, string storedProcedureName, params object[] parameterValues)
        {
            DataSet set = null;
            DateTime now = DateTime.Now;
            try
            {
                set = this._db.ExecuteDataSet(transaction, storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataSet成功（通过存储过程）] ", storedProcedureName, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", set.Tables[0].Rows.Count, "]-[影响列数：", set.Tables[0].Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "（通过存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return set;
        }

        public DataTable ExecuteDataTable(DbCommand command)
        {
            DataTable dataTable = null;
            DateTime now = DateTime.Now;
            try
            {
                dataTable = new DataTable(GetSingleTableName(command.CommandText));
                DbDataAdapter dataAdapter = this._db.GetDataAdapter();
                dataAdapter.SelectCommand = command;
                dataAdapter.Fill(dataTable);
                dataAdapter.Dispose();
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataTable成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", dataTable.Rows.Count, "]-[影响列数：", dataTable.Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return dataTable;
        }

        public DataTable ExecuteDataTable(string commandText)
        {
            DataTable dataTable = null;
            DateTime now = DateTime.Now;
            try
            {
                dataTable = new DataTable(GetSingleTableName(commandText));
                DbDataAdapter dataAdapter = this._db.GetDataAdapter();
                DbCommand sqlStringCommand = this._db.GetSqlStringCommand(commandText);
                dataAdapter.SelectCommand = sqlStringCommand;
                sqlStringCommand.Connection = this._db.CreateConnection();
                sqlStringCommand.Connection.Open();
                dataAdapter.Fill(dataTable);
                sqlStringCommand.Connection.Close();
                sqlStringCommand.Connection.Dispose();
                sqlStringCommand.Dispose();
                dataAdapter.Dispose();
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataTable成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", dataTable.Rows.Count, "]-[影响列数：", dataTable.Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return dataTable;
        }

        public DataTable ExecuteDataTable(DbCommand command, DbTransaction transaction)
        {
            DataTable dataTable = null;
            DateTime now = DateTime.Now;
            try
            {
                dataTable = new DataTable(GetSingleTableName(command.CommandText));
                DbDataAdapter dataAdapter = this._db.GetDataAdapter();
                dataAdapter.SelectCommand = command;
                command.Transaction = transaction;
                dataAdapter.Fill(dataTable);
                dataAdapter.Dispose();
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataTable成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", dataTable.Rows.Count, "]-[影响列数：", dataTable.Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return dataTable;
        }

        public DataTable ExecuteDataTable(string commandText, DbTransaction transaction)
        {
            DataTable dataTable = null;
            DateTime now = DateTime.Now;
            try
            {
                dataTable = new DataTable(GetSingleTableName(commandText));
                DbDataAdapter dataAdapter = this._db.GetDataAdapter();
                DbCommand command = transaction.Connection.CreateCommand();
                command.CommandText = commandText;
                dataAdapter.SelectCommand = command;
                command.Transaction = transaction;
                dataAdapter.Fill(dataTable);
                command.Dispose();
                dataAdapter.Dispose();
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataTable成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n[影响行数：", dataTable.Rows.Count, "]-[影响列数：", dataTable.Columns.Count, "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataTable失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return dataTable;
        }

        public int ExecuteNonQuery(DbCommand command)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(command);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int ExecuteNonQuery(string commandText)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(CommandType.Text, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int ExecuteNonQuery(CommandType commandType, string commandText)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(commandType, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int[] ExecuteNonQuery(CommandType commandType, string[] arrCommandText)
        {
            int[] numArray = null;
            int num;
            string str;
            DateTime now = DateTime.Now;
            try
            {
                numArray = new int[arrCommandText.Length];
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    numArray[num] = this._db.ExecuteNonQuery(commandType, arrCommandText[num]);
                }
                if (!this.logFlag)
                {
                    return numArray;
                }
                TimeSpan span = (TimeSpan)(DateTime.Now - now);
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL成功] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(string.Concat(new object[] { str, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
            }
            catch (Exception exception)
            {
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL失败：" + exception.Message + "] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(str + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return numArray;
        }

        public int ExecuteNonQuery(DbCommand command, DbTransaction transaction)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(command, transaction);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int ExecuteNonQuery(DbTransaction transaction, string commandText)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(transaction, CommandType.Text, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", storedProcedureName, "（存储过程）-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "（存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int[] ExecuteNonQuery(CommandType commandType, string[] arrCommandText, bool allowInterrupt)
        {
            int[] numArray = new int[arrCommandText.Length];
            DateTime now = new DateTime();
            bool flag = false;
            string str = null;
            DateTime time2 = new DateTime();
            TimeSpan span = new TimeSpan();
            this.dtError.Rows.Clear();
            for (int i = 0; i < arrCommandText.Length; i++)
            {
                object obj2;
                try
                {
                    now = DateTime.Now;
                    numArray[i] = this._db.ExecuteNonQuery(commandType, arrCommandText[i]);
                    if (this.logFlag)
                    {
                        span = (TimeSpan)(DateTime.Now - now);
                        obj2 = str;
                        str = string.Concat(new object[] { obj2, this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", arrCommandText[i], "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n" });
                    }
                }
                catch (Exception exception)
                {
                    string str3;
                    if (allowInterrupt)
                    {
                        obj2 = str;
                        str = string.Concat(new object[] { obj2, this._boinfo, "[", this._dbinfo, "][执行第 ", i + 1, " 行SQL失败：", exception.Message });
                        str3 = str.Remove(str.Length - 2);
                        Log4net.WriteDACLog(str3 + "] " + arrCommandText[i] + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]\r\n");
                        this.dtError.Rows.Add(new object[] { i, exception.Message, arrCommandText[i] });
                        throw new Exception("DAC访问错误：" + exception.Message);
                    }
                    obj2 = str;
                    str = string.Concat(new object[] { obj2, this._boinfo, "[", this._dbinfo, "][执行第 ", i + 1, " 行SQL失败：", exception.Message });
                    str3 = str.Remove(str.Length - 2);
                    str = str3 + "] " + arrCommandText[i] + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]\r\n";
                    this.dtError.Rows.Add(new object[] { i, exception.Message, arrCommandText[i] });
                    flag = true;
                }
            }
            if (this.logFlag)
            {
                if (flag)
                {
                    Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][批量执行SQL失败] \r\n" + str.Remove(str.Length - 2));
                }
                else
                {
                    string str2 = this._boinfo + "[" + this._dbinfo + "][批量执行SQL成功] \r\n";
                    Log4net.WriteDACLog(str);
                }
            }
            if (flag)
            {
                throw new Exception("DAC批量执行错误");
            }
            return numArray;
        }

        public int ExecuteNonQuery(DbConnection dbcon, DbCommand cmd, DbTransaction trans)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = cmd.ExecuteNonQuery();
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", cmd.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + cmd.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int ExecuteNonQuery(DbTransaction transaction, CommandType commandType, string commandText)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(transaction, commandType, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int[] ExecuteNonQuery(DbTransaction transaction, CommandType commandType, string[] arrCommandText)
        {
            int[] numArray = null;
            int num;
            string str;
            DateTime now = DateTime.Now;
            try
            {
                numArray = new int[arrCommandText.Length];
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    numArray[num] = this._db.ExecuteNonQuery(transaction, commandType, arrCommandText[num]);
                }
                TimeSpan span = (TimeSpan)(DateTime.Now - now);
                if (!this.logFlag)
                {
                    return numArray;
                }
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL成功] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(string.Concat(new object[] { str, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
            }
            catch (Exception exception)
            {
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL失败：" + exception.Message + "] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(str + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return numArray;
        }

        public int ExecuteNonQuery(DbTransaction transaction, string storedProcedureName, params object[] parameterValues)
        {
            int num = -1;
            DateTime now = DateTime.Now;
            try
            {
                num = this._db.ExecuteNonQuery(transaction, storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", storedProcedureName, "（存储过程）-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "（存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return num;
        }

        public int[] ExecuteNonQuery(DbTransaction transaction, CommandType commandType, string[] arrCommandText, bool allowInterrupt)
        {
            int[] numArray = new int[arrCommandText.Length];
            DateTime now = new DateTime();
            bool flag = false;
            string str = null;
            DateTime time2 = new DateTime();
            TimeSpan span = new TimeSpan();
            this.dtError.Rows.Clear();
            for (int i = 0; i < arrCommandText.Length; i++)
            {
                object obj2;
                try
                {
                    now = DateTime.Now;
                    numArray[i] = this._db.ExecuteNonQuery(transaction, commandType, arrCommandText[i]);
                    if (this.logFlag)
                    {
                        span = (TimeSpan)(DateTime.Now - now);
                        obj2 = str;
                        str = string.Concat(new object[] { obj2, this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", arrCommandText[i], "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]\r\n" });
                    }
                }
                catch (Exception exception)
                {
                    string str3;
                    if (allowInterrupt)
                    {
                        obj2 = str;
                        str = string.Concat(new object[] { obj2, this._boinfo, "[", this._dbinfo, "][执行第 ", i + 1, " 行SQL失败：", exception.Message });
                        str3 = str.Remove(str.Length - 2);
                        Log4net.WriteDACLog(str3 + "] " + arrCommandText[i] + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                        this.dtError.Rows.Add(new object[] { i, exception.Message, arrCommandText[i] });
                        throw new Exception("DAC访问错误：" + exception.Message);
                    }
                    obj2 = str;
                    str = string.Concat(new object[] { obj2, this._boinfo, "[", this._dbinfo, "][执行第 ", i + 1, " 行SQL失败：", exception.Message });
                    str3 = str.Remove(str.Length - 2);
                    str = str3 + "] " + arrCommandText[i] + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]\r\n";
                    this.dtError.Rows.Add(new object[] { i, exception.Message, arrCommandText[i] });
                    flag = true;
                }
            }
            if (this.logFlag)
            {
                if (flag)
                {
                    Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][批量执行SQL失败] \r\n" + str.Remove(str.Length - 2));
                }
                else
                {
                    string str2 = this._boinfo + "[" + this._dbinfo + "][批量执行SQL成功] \r\n";
                    Log4net.WriteDACLog(str);
                }
            }
            if (flag)
            {
                throw new Exception("DAC批量执行错误");
            }
            return numArray;
        }

        public IDataReader ExecuteReader(DbCommand command)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(command);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public IDataReader ExecuteReader(string commandText)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(CommandType.Text, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public IDataReader ExecuteReader(CommandType commandType, string commandText)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(commandType, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public IDataReader ExecuteReader(DbCommand command, DbTransaction transaction)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(command, transaction);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public IDataReader ExecuteReader(DbTransaction transaction, string commandText)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(transaction, CommandType.Text, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public IDataReader ExecuteReader(string storedProcedureName, params object[] parameterValues)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", storedProcedureName, "（存储过程）-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "（存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public IDataReader ExecuteReader(DbTransaction transaction, CommandType commandType, string commandText)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(transaction, commandType, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public IDataReader ExecuteReader(DbTransaction transaction, string storedProcedureName, params object[] parameterValues)
        {
            IDataReader reader = null;
            DateTime now = DateTime.Now;
            try
            {
                reader = this._db.ExecuteReader(transaction, storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][获取DataReader成功] ", storedProcedureName, "（存储过程）-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][获取DataReader失败：" + exception.Message + "（存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return reader;
        }

        public object ExecuteScalar(DbCommand command)
        {
            object obj2 = null;
            DateTime now = DateTime.Now;
            try
            {
                obj2 = this._db.ExecuteScalar(command);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return obj2;
        }

        public object ExecuteScalar(CommandType commandType, string commandText)
        {
            object obj2 = null;
            DateTime now = DateTime.Now;
            try
            {
                obj2 = this._db.ExecuteScalar(commandType, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return obj2;
        }

        public object[] ExecuteScalar(CommandType commandType, string[] arrCommandText)
        {
            object[] objArray = null;
            int num;
            string str;
            DateTime now = DateTime.Now;
            try
            {
                objArray = new object[arrCommandText.Length];
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    objArray[num] = this._db.ExecuteScalar(commandType, arrCommandText[num]);
                }
                if (!this.logFlag)
                {
                    return objArray;
                }
                TimeSpan span = (TimeSpan)(DateTime.Now - now);
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL成功] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(string.Concat(new object[] { str, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
            }
            catch (Exception exception)
            {
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL失败：" + exception.Message + "] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(str + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return objArray;
        }

        public object ExecuteScalar(DbCommand command, DbTransaction transaction)
        {
            object obj2 = null;
            DateTime now = DateTime.Now;
            try
            {
                obj2 = this._db.ExecuteScalar(command, transaction);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", command.CommandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + command.CommandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return obj2;
        }

        public object ExecuteScalar(string storedProcedureName, params object[] parameterValues)
        {
            object obj2 = null;
            DateTime now = DateTime.Now;
            try
            {
                obj2 = this._db.ExecuteScalar(storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", storedProcedureName, "（通过存储过程）-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "（通过存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return obj2;
        }

        public object ExecuteScalar(DbTransaction transaction, CommandType commandType, string commandText)
        {
            object obj2 = null;
            DateTime now = DateTime.Now;
            try
            {
                obj2 = this._db.ExecuteScalar(transaction, commandType, commandText);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", commandText, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "] " + commandText + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return obj2;
        }

        public object[] ExecuteScalar(DbTransaction transaction, CommandType commandType, string[] arrCommandText)
        {
            object[] objArray = null;
            int num;
            string str;
            DateTime now = DateTime.Now;
            try
            {
                objArray = new object[arrCommandText.Length];
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    objArray[num] = this._db.ExecuteScalar(transaction, commandType, arrCommandText[num]);
                }
                if (!this.logFlag)
                {
                    return objArray;
                }
                TimeSpan span = (TimeSpan)(DateTime.Now - now);
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL成功] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(string.Concat(new object[] { str, "-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
            }
            catch (Exception exception)
            {
                str = this._boinfo + "[" + this._dbinfo + "][批量执行SQL失败：" + exception.Message + "] \r\n";
                for (num = 0; num < arrCommandText.Length; num++)
                {
                    str = str + arrCommandText[num] + "\r\n";
                }
                Log4net.WriteDACLog(str + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return objArray;
        }

        public object ExecuteScalar(DbTransaction transaction, string storedProcedureName, params object[] parameterValues)
        {
            object obj2 = null;
            DateTime now = DateTime.Now;
            try
            {
                obj2 = this._db.ExecuteScalar(transaction, storedProcedureName, parameterValues);
                if (this.logFlag)
                {
                    TimeSpan span = (TimeSpan)(DateTime.Now - now);
                    Log4net.WriteDACLog(string.Concat(new object[] { this._boinfo, "[", this._dbinfo, "][执行SQL成功] ", storedProcedureName, "（通过存储过程）-[耗时：", span.TotalMilliseconds, "毫秒]-[开始时间：", now.ToShortDateString(), now.ToShortTimeString(), "]" }));
                }
            }
            catch (Exception exception)
            {
                Log4net.WriteDACLog(this._boinfo + "[" + this._dbinfo + "][执行SQL失败：" + exception.Message + "（通过存储过程）] " + storedProcedureName + "-[开始时间：" + now.ToShortDateString() + now.ToShortTimeString() + "]");
                throw new Exception("DAC访问错误：" + exception.Message);
            }
            return obj2;
        }

        public DbDataAdapter GetDataAdapter()
        {
            return this._db.GetDataAdapter();
        }

        public object GetInstrumentationEventProvider()
        {
            return this._db.GetInstrumentationEventProvider();
        }

        public object GetParameterValue(DbCommand command, string name)
        {
            return this._db.GetParameterValue(command, name);
        }

        public DataTable getPKInfo(string sTableName)
        {
            string commandText = "select c.table_name, c.column_name, b.CONSTRAINT_TYPE, c.DATA_TYPE ";
            commandText = ((((commandText + "  from user_cons_columns a, user_CONSTRAINTS b, user_tab_columns c ") + " where a.table_name = b.table_name                                 " + "   and a.owner = b.owner                                           ") + "   and a.CONSTRAINT_NAME = b.CONSTRAINT_NAME                       " + "   and a.table_name = c.table_name                                 ") + "   and a.column_name = c.column_name                               " + "   and b.CONSTRAINT_TYPE = 'P'                                     ") + "   and c.table_name = '" + sTableName.ToUpper() + "'               ";
            return this.ExecuteDataTable(commandText);
        }

        private static string GetSingleTableName(string SelectText)
        {
            string str = SelectText;
            str = str.ToUpper();
            int index = str.IndexOf(" GROUP ");
            if (index > 0)
            {
                str = str.Substring(0, index);
            }
            index = str.IndexOf(" ORDER ");
            if (index > 0)
            {
                str = str.Substring(0, index);
            }
            index = str.IndexOf(" WHERE ");
            if (index > 0)
            {
                str = str.Substring(0, index);
            }
            int num2 = str.IndexOf(" FROM ");
            string[] strArray = str.Substring(num2 + 6, (str.Length - num2) - 6).Trim().Split(new char[] { ',' });
            for (int i = 0; i < strArray.Length; i++)
            {
                int startIndex = strArray[i].IndexOf(" ");
                if (startIndex > 0)
                {
                    strArray[i] = strArray[i].Remove(startIndex, strArray[i].Length - startIndex);
                }
            }
            return strArray[0];
        }

        public DbCommand GetSqlStringCommand(string query)
        {
            return this._db.GetSqlStringCommand(query);
        }

        public DbCommand GetStoredProcCommand(string storedProcedureName)
        {
            return this._db.GetStoredProcCommand(storedProcedureName);
        }

        public DbCommand GetStoredProcCommand(string storedProcedureName, params object[] parameterValues)
        {
            return this._db.GetStoredProcCommand(storedProcedureName, parameterValues);
        }

        public DbCommand GetStoredProcCommandWithSourceColumns(string storedProcedureName, params string[] sourceColumns)
        {
            return this._db.GetStoredProcCommand(storedProcedureName, sourceColumns);
        }

        public void PrepareCommand(DbCommand cmd, DbConnection conn, DbTransaction trans, string cmdText, params object[] cmdParms)
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            cmd.Connection = conn;
            cmd.CommandText = cmdText;
            if (trans != null)
            {
                cmd.Transaction = trans;
            }
            cmd.CommandType = CommandType.Text;
            if (cmdParms != null)
            {
                foreach (object obj2 in cmdParms)
                {
                    cmd.Parameters.Add(obj2);
                }
            }
        }

        public void SetParameterValue(DbCommand command, string parameterName, object value)
        {
            this._db.SetParameterValue(command, parameterName, value);
        }

        public int[] UpdateDataSet(DataSet dataSet)
        {
            return this._updateDataSet(dataSet, null, null);
        }

        private int[] _updateDataSet(DataSet dataSet, DbConnection dbConn, DbTransaction dbTransaction)
        {
            int[] numArray = new int[dataSet.Tables.Count];
            for (int i = 0; i < dataSet.Tables.Count; i++)
            {
                numArray[i] = this._updateDataTable(dataSet.Tables[i], dbConn, dbTransaction);
            }
            return numArray;
        }
        private int _updateDataTable(DataTable dataTable, DbConnection dbConnection, DbTransaction dbTransaction)
        {
            return 0;
        }

        public int[] UpdateDataSet(DataSet dataSet, DbConnection dbConn, DbTransaction dbTransaction)
        {
            return this._updateDataSet(dataSet, dbConn, dbTransaction);
        }

        public int UpdateDataTable(DataTable dataTable)
        {
            return this._updateDataTable(dataTable, null, null);
        }

        public int UpdateDataTable(DataTable dataTable, DbConnection dbconn, DbTransaction dbTransaction)
        {
            return this._updateDataTable(dataTable, dbconn, dbTransaction);
        }

        #endregion


        #region Properties
        public string BOInfo
        {
            get
            {
                return this._boinfo;
            }
            set
            {
                this._boinfo = value;
            }
        }

        public string ConnString
        {
            get
            {
                try
                {
                    if (this._connstring == string.Empty)
                    {
                        this._connstring = Server.GetSystemConnectionString();
                    }
                }
                catch
                {
                    this._connstring = "";
                }
                return this._connstring;
            }
            set
            {
                this._connstring = value;
                if (this._connstring.IndexOf("DATA SOURCE=") >= 0)
                {
                    this._connstring = this._connstring.Substring(this._connstring.IndexOf("DATA SOURCE="));
                }
                string providerName = this.ProviderName;
                if (providerName != null)
                {
                    if (!(providerName == "System.Data.OracleClient"))
                    {
                        if (providerName == "System.Data.SqlClient")
                        {
                            this._db = new SqlDatabase(this._connstring);
                            string[] strArray = this._connstring.Split(new char[] { ';' });
                            string str = strArray[0].Split(new char[] { '=' })[1];
                            string str2 = strArray[1].Split(new char[] { '=' })[1];
                            this._dbinfo = str + "." + str2;
                        }
                    }
                    else
                    {
                        this._db = new OracleDatabase(this._connstring);
                        string[] strArray = this._connstring.Split(new char[] { ';' });
                        string str = strArray[0].Split(new char[] { '=' })[1];
                        string str2 = strArray[1].Split(new char[] { '=' })[1];
                        this._dbinfo = str + "." + str2;
                    }
                }
                this._db = new GenericDatabase(this._connstring, DbProviderFactories.GetFactory(this._providerName));
            }
        }

        public string CorpCode
        {
            get
            {
                return this._corpCode;
            }
            set
            {
                this._corpCode = value;
            }
        }

        public string ProviderName
        {
            get
            {
                if (this._providerName == string.Empty)
                {
                    this._providerName = "System.Data.OracleClient";
                }
                return this._providerName;
            }
            set
            {
                this._providerName = value;
            }
        }

        public string DataConnString
        {
            get
            {
                if (string.IsNullOrEmpty(this._dataConnString))
                {
                    this._dataConnString = Server.GetSystemConnectionString();
                }
                return this._dataConnString;
            }
            set
            {
                this._dataConnString = value;
            }
        }

        public Database DB
        {
            get
            {
                return this._db;
            }
        }

        public DataTable DtError
        {
            get
            {
                return this.dtError;
            }
        }

        public string SystemConnString
        {
            get
            {
                if (string.IsNullOrEmpty(this._systemConnString))
                {
                    string systemConnectionString = Server.GetSystemConnectionString();
                    this._systemConnString = systemConnectionString.Substring(systemConnectionString.IndexOf("DATA SOURCE="));
                }
                return this._systemConnString;
            }
            set
            {
                this._systemConnString = value;
            }
        }
        #endregion

        


        // Nested Types
        public enum ConnPositionEnum
        {
            System,
            Data
        }

        public enum providerName
        {
            Oracle,
            SqlServer,
            OleDb,
            Odbc
        }
    }
}
